package netty2;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.ByteBuffer;

public class bufdemo {

    public static void main(String[] args) {
        ByteBuf buffer = Unpooled.buffer(10);
        System.out.println(buffer);

        for(int i = 0;i<8;i++){
            buffer.writeByte(i);
        }
        System.out.println(buffer);


        buffer.markReaderIndex();
        for (int i = 0; i < 2; i++) {
            byte b = buffer.readByte();
            System.out.println(b);

        }
//        buffer.resetReaderIndex();
        for (int i = 0; i < 2; i++) {
            byte b = buffer.readByte();
            System.out.println(b);

        }
        System.out.println(buffer);

        System.out.println(buffer);
    }
}
